﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace FaultDiagnosisSystem.DAL
{
    public class Component
    {
        /// <summary>
        /// 获取有传感器数据的部件集合
        /// </summary>
        /// <returns></returns>
        internal IList<Models.DataModels.Component> GetListWithSensorData()
        {
            using (Models.DataModels.TurbineFaultContext context=new Models.DataModels.TurbineFaultContext())
            {
                return context.Component
                    .Where(c=>c.HasSensorData==true)
                    .ToList();
            }
        }

        /// <summary>
        /// 组件：传感器字典
        /// </summary>
        /// <returns></returns>
        internal Dictionary<int,Models.DataModels.Component> GetDictWithSensorData()
        {
            using (Models.DataModels.TurbineFaultContext context = new Models.DataModels.TurbineFaultContext())
            {
                return context.Component
                    .Where(c => c.HasSensorData == true)
                    .Include(c => c.Sensor)
                    .ToDictionary(c=>c.ComponentId);
            }
        }
    }
}